<template>
  <div class="Son1">
      <!-- <button @click="sendTo">点击传给父组件</button> -->
      <button @click="sendTo">点击传兄弟组件</button>
      <p>这是显示来自父组件的值:{{datas}}</p>
      <p>这是显示来自兄弟组件的值:</p>
  </div>
</template>

<script>
export default {
    name: 'Son1',
    props:['datas'],
    data(){
        return {
            msg:'I come from China',
            age: 25
        }
    },
    methods:{
        sendTo(){
            // this.$emit('sendMsg',this.msg)
            this.$root.$emit('sendToB',this.age)
            // console.log(this.$root);
        }
    },
    mounted(){
        this.$root.$emit('sendToB',this.age)
    }
}
</script>

<style>

</style>